package com.example.administrator.capital.presenter;
import com.example.administrator.capital.model.LoginModel;
import com.example.administrator.capital.model.base.IActionRequest;
import com.example.administrator.capital.presenter.base.BasePresenter;
import com.example.administrator.capital.presenter.base.IViewBase;
import com.example.administrator.capital.presenter.base.IViewRequest;
import com.lzy.okgo.model.Response;

/**
 * Created by Administrator on 2017/12/1 0001.
 * 交互层
 *
 */
public class LoginPresenter extends BasePresenter {
    private LoginModel mLoginModel;
    public LoginPresenter(IViewBase iViewBase) {
        super(iViewBase);
        mLoginModel = new LoginModel();
    }

    /**
     * @param iViewRequest
     * @param username
     * @param password
     * @param tel
     * 注册
     */
    public void register(final IViewRequest<String>iViewRequest,String username, String password, String tel,String Telbind){
        mLoginModel.register(new IActionRequest<String>() {
            @Override
            public void success(Response<String> data) {
                iViewRequest.onSuccess(data);
            }

            @Override
            public void fail(Response<String> error) {
                iViewRequest.onFail(error);
            }

            @Override
            public void failMsg(String var) {
                iViewRequest.onFailMsg(var);
            }

            @Override
            public void code(int code) {
                iViewRequest.onCode(code);
            }
        },username,password,tel,Telbind);
    }


    /**
     * @param iViewRequest
     * @param username
     * @param password
     * 登录
     */
    public void getSign(final IViewRequest<String> iViewRequest,String username, String password){
    mLoginModel.getSign(new IActionRequest<String>() {
        @Override
        public void success(Response<String> data) {
            iViewRequest.onSuccess(data);
        }
        @Override
        public void fail(Response<String> error) {
            iViewRequest.onFail(error);
        }

        @Override
        public void failMsg(String var) {
            iViewRequest.onFailMsg(var);
        }

        @Override
        public void code(int code) {
            iViewRequest.onCode(code);
        }
    },username,password);


}
    public void getYZM(final IViewRequest<String> iViewRequest,String mobile){
        mLoginModel.getYZM(new IActionRequest<String>() {
            @Override
            public void success(Response<String> data) {
                iViewRequest.onSuccess(data);
            }

            @Override
            public void fail(Response<String> error) {
                iViewRequest.onFail(error);
            }

            @Override
            public void failMsg(String var) {
                iViewRequest.onFailMsg(var);
            }

            @Override
            public void code(int code) {
                iViewRequest.onCode(code);
            }
        },mobile);

    }


}
